<template>
  <div class="app">
    <h2>当前计数{{ counter }}</h2>
    <button @click="add">+!</button>
    <button @click="sub">-1</button>
  </div>
</template>

<!-- <script>
  import { ref } from 'vue';
export default {
  setup() {
    let counter=ref(0)
    const add=()=>{
      counter.value++
    }
    const sub=()=>{
      counter.value--
    }
    return {
      counter,
      add,
      sub
    }
  },
}
</script> -->

<script setup>
import { ref } from 'vue'
let counter = ref(0)
const add = () => {
  counter.value++
}
const sub = () => {
  counter.value--
}
</script>
<style></style>
